﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System
{
    public static class StaticExtensionMethod
    {
        public static string FullMsg(this Exception ex)
        {
            if (ex != null && ex.InnerException != null)
            {
                return ex.Message + " -> " + ex.InnerException.FullMsg();
            }
            else if (ex != null && ex.InnerException == null)
            {
                return ex.Message;
            }
            else
            {
                return string.Empty;
            }
        }

        public static string DecodeToString(this Byte[] obj)
        {
            if (obj == null)
                return string.Empty;
            return System.Text.Encoding.Default.GetString(obj);
        }

        public static Byte[] EncodeToByteArray(this String obj)
        {
            if (obj == null)
                obj = string.Empty;
            return System.Text.Encoding.Default.GetBytes(obj);
        }
    }
}
